﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;
using System.Web.UI.WebControls;
using System.Web.UI;
using System.Security.Permissions;
using System.ComponentModel;

namespace Basic4Net.Controls
{
    /// <summary>
    /// 功能：扩展TextBox控件
    /// 修改记录：1.2007-06-13 扩展必须控制输入类型包括文本、数字等。
    ///           2.2007-06-16 添加验证功能，包括非空、范围、规则验证。
    ///           3.2007-07-05 添加危险字符验证功能。
    /// </summary>
    [AspNetHostingPermission(SecurityAction.Demand, Level = AspNetHostingPermissionLevel.Minimal),
     AspNetHostingPermission(SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal),
     ToolboxData("<{0}:BNTextBox runat=\"server\"></{0}:BNTextBox>")]
    public class BNTextBox : TextBox
    {
        #region 常量
        private static class txtConstants
        {
            #region 客户端脚本注册名称
            public static string strRegName = "reginputScript";
            public static string strRegEnterName = "baseTextBoxEnter";
            public static string strRangeScirpt = "ValidatorForLength";
            #endregion

            #region 验证表达式
            public static string valChineseLanguage = @"/^[\u4E00-\u9FA5]*$/";
            public static string valInt = @"/^\-?[0-9]*$/";
            public static string valFloat = @"/^\-?\d*\.?\d{0,{0}}$/";
            public static string valPhone = @"/^\d{1,4}([-\/](\d{1,8}?)?)?$/";
            public static string valUpper = @"/^[A-Z]*$/";
            public static string valLower = @"/^[a-z]*$/";
            public static string valEMail = @"\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*";
            public static string valDanger = "(<\\d+)?[^<]*(<+\\d+[^<]*)*[^<]*(\\s|\\S)?";
            #endregion 

            #region 客户端事件
            public static string Onkeypress = @"return regInput(this,	{0},String.fromCharCode(event.keyCode))";
            public static string Onpaste = @"return regInput(this,{0},window.clipboardData.getData('Text'))";
            public static string Ondrop = @"return regInput(this,{0},event.dataTransfer.getData('Text'))";
            public static string OnfocusCloseInput = "this.style.imeMode='disabled'";
            public static string OnfocusDate = "calendar(this,{0},'{1}','{2}');";
            #endregion

            #region 验证信息
            public static string MsgValNameFormat = "[{0}]";//验证名字格式
            public static string MsgEmpty = "Please specify the {0}.";
            public static string MsgRegular = "This is not a valid {0}";
            public static string MsgRange = "{0} should be between [{1}] and [{2}].";
            public static string MsgRangeString = "{0} should be {1} characters.";
            public static string MsgRangeStringMin = "less than [{0}]";
            public static string MsgRangeStringMax = "more than [{0}]";
            public static string MsgDanger = "The inputs of {0} have dangerous symbols.";
            #endregion
        }
        #endregion

        #region 验证

        #region --- 验证公共属性
        private string strValName = "";
        [Category("Validator"), Description("验证名")]
        public string ValName
        {
            get { return this.strValName; }
            set { this.strValName = value; }
        }

        private ValidatorDisplay eDisplay = ValidatorDisplay.Dynamic;
        [Category("Validator"), Description("验证显示格式")]
        public ValidatorDisplay Display
        {
            get { return this.eDisplay; }
            set { this.eDisplay = value; }
        }

        #region --- 验证危险字符
        RegularExpressionValidator ctrValDanger = new RegularExpressionValidator();

        private bool blValDanger = false;
        [Category("Validator"), Description("是否验证危险字符")]
        public bool IsValDanger
        {
            get { return this.blValDanger; }
            set { this.blValDanger = value; }
        }

        #endregion
        #endregion

        #region --- 非空验证控件
        private RequiredFieldValidator ctrValEmpty = new RequiredFieldValidator();
        private bool blValEmpty = false;
        [Category("ValidatorEmpty"), Description("是否非空验证")]
        public bool IsValEmpty
        {
            get { return this.blValEmpty; }
            set { this.blValEmpty = value; }
        }

        [Category("ValidatorEmpty"), Description("自定义非空验证消息")]
        public string ValEmptyMsg
        {
            get { return this.ctrValEmpty.ErrorMessage; }
            set { this.ctrValEmpty.ErrorMessage = value; }
        }
        #endregion

        #region --- 规则验证控件
        public enum ERegularType
        {
            Custom,
            EMail,
        }

        RegularExpressionValidator ctrValRegular = new RegularExpressionValidator();

        private bool blValRegular = false;
        [Category("ValidatorRegular"), Description("是否规则验证")]
        public bool IsValRegular
        {
            get { return this.blValRegular; }
            set { this.blValRegular = value; }
        }

        private ERegularType eRegularType;
        [Category("ValidatorRegular"), Description("规则验证类型")]
        public ERegularType RegularType
        {
            get { return this.eRegularType; }
            set
            {
                switch (value)
                {
                    case ERegularType.EMail:
                        this.ValExpression = txtConstants.valEMail;
                        break;
                    default:
                        this.ValExpression = "";
                        break;
                }
                this.eRegularType = value;
            }
        }

        [Category("ValidatorRegular"), Description("规则验证表达式")]
        public string ValExpression
        {
            get { return this.ctrValRegular.ValidationExpression; }
            set { this.ctrValRegular.ValidationExpression = value; }
        }

        [Category("ValidatorRegular"), Description("自定义规则验证消息")]
        public string ValRegularMsg
        {
            get { return this.ctrValRegular.ErrorMessage; }
            set { this.ctrValRegular.ErrorMessage = value; }
        }
        #endregion

        #region --- 范围验证控件
        RangeValidator ctrValRange = new RangeValidator();

        CustomValidator ctrValRangeString = new CustomValidator();

        private bool blValRange = false;
        [Category("ValidatorRange"), Description("是否范围验证")]
        public bool IsValRange
        {
            get { return this.blValRange; }
            set { this.blValRange = value; }
        }

        [Category("ValidatorRange"), Description("范围验证最大值")]
        public string MaxValue
        {
            get { return this.ctrValRange.MaximumValue; }
            set { this.ctrValRange.MaximumValue = value; }
        }

        [Category("ValidatorRange"), Description("范围验证最小值")]
        public string MinValue
        {
            get { return this.ctrValRange.MinimumValue; }
            set { this.ctrValRange.MinimumValue = value; }
        }

        [Category("ValidatorRange"), Description("自定义范围验证消息")]
        public string ValRangeMsg
        {
            get { return this.ctrValRange.ErrorMessage; }
            set { this.ctrValRange.ErrorMessage = value; }
        }
        #endregion

        #region --- 比较验证
        //private string strCompareControlID = "";
        //[Category("ValidatorRange"), Description("比较验证控件ID")]
        //public string CompareControlID
        //{
        //    get { return this.strCompareControlID; }
        //    set { this.strCompareControlID = value; }
        //}
        #endregion

        #endregion

        #region 输入文本类型
        /// <summary>
        /// 文本类型
        /// </summary>
        public enum textType
        {
            /// <summary>
            /// 任意文本
            /// </summary>
            String,
            /// <summary>
            /// 大写字母
            /// </summary>
            Upper,
            /// <summary>
            /// 小写
            /// </summary>
            Lower,
            /// <summary>
            /// 数字
            /// </summary>
            Int,
            /// <summary>
            /// 小数
            /// </summary>
            Float, 
            /// <summary>
            /// 中文
            /// </summary>
            ChineseLanguage,// 中文
            /// <summary>
            /// 固定电话
            /// </summary>
            Phone,
        }
        #endregion

        #region 属性
        public override string Text
        {
            get{return base.Text.TrimEnd();}
            set{base.Text = value==null ? string.Empty : value.TrimEnd();}
        }

        private textType inputtype;
        /// <summary>
        /// 文本框录入的模式
        /// </summary>
        [Category("CustProperty"), Description(@"文本框输入的类型")]
        public textType InputType
        {
            get { return inputtype; }
            set
            {
                if ((value < textType.String) || (value > textType.Phone))
                {
                    throw new ArgumentOutOfRangeException("无效属性值");
                }
                inputtype = value;
            }
        }

        //private string showMessage;
        ///// <summary>
        ///// 验证用户不通过的友好提示信息
        ///// </summary>
        //[Category("CustProperty"), Description("验证用户不通过的友好提示信息")]
        //[DefaultValue("请在此输入当验证数据不通过的友好提示！")]
        //public string ShowMessage
        //{
        //    get { return this.showMessage; }
        //    set
        //    {
        //        if (value.Length > 50)
        //            throw new ArgumentOutOfRangeException("提示超出长度，50字符以内");
        //        this.showMessage = value;
        //    }
        //}
        private string OnfocusCss;
        /// <summary>
        /// 控件得到焦点的样式
        /// </summary>
        [Category("CustProperty"), Description("得到焦点或鼠标移上文本框的样式名称")]
        [DefaultValue("请在此输入当该文本框得到焦点样式的名称！")]
        public string OnFocusCssName
        {
            get { return this.OnfocusCss; }
            set { this.OnfocusCss = value; }
        }

        private string OnblurCss;
        /// <summary>
        /// 控件得到焦点的样式
        /// </summary>
        [Category("CustProperty"), Description("失去焦点或鼠标移开文本框的样式名称")]
        [DefaultValue("请在此输入当该文本框失去焦点样式的名称！")]
        public string OnBlurCssName
        {
            get { return OnblurCss; }
            set { this.OnblurCss = value; }
        }

        private string floatlength = "2";
        /// <summary>
        /// 当是浮点数时，指定小数位数
        /// </summary>
        [Category("CustProperty"), Description("当是浮点数时,指定保留的小数位数")]
        public string FloatLength
        {
            get
            { return this.floatlength; }
            set
            {
                if (Int64.Parse(value) < 0)
                    throw new ArgumentOutOfRangeException("小数位数至少保留一位小数,如无需保留请选择整形");
                this.floatlength = value;
            }
        }

        ///// <summary>
        ///// 保存特定的值
        ///// </summary>
        //[Category("CustProperty"), Description("用于保存文本框的特定值，指定值的对应编号")]
        //[DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
        //public string textValue
        //{
        //    get
        //    {
        //        string text1 = (string)this.ViewState["textValue"];
        //        if (text1 != null)
        //        {
        //            return text1;
        //        }
        //        return string.Empty;
        //    }
        //    set
        //    {
        //        this.ViewState["textValue"] = value;
        //    }
        //}

        /// <summary>
        /// 设置是否ReadOnly
        /// </summary>
        [Category("CustProperty"), Description("ReadOnly")]
        public bool IsReadOnly
        {
            get { return (this.Attributes["readonly"] != null); }
            set { if(value)this.Attributes["readonly"] = "readonly"; }
        }
        #endregion

        #region 重写基类方法
        /// <summary>
        /// 重写Html输出函数
        /// </summary>
        /// <param name="writer">要写出到的 HTML 编写器</param>
        protected override void Render(HtmlTextWriter writer)
        {
            base.Render(writer);
            //if (this.blValEmpty)
            //{
            //    writer.AddStyleAttribute(HtmlTextWriterStyle.Color, "Red");
            //    writer.RenderBeginTag(HtmlTextWriterTag.Span);
            //    writer.Write(" *");
            //    writer.RenderEndTag();
            //}
            #region 输出验证控件
            if (eDisplay != ValidatorDisplay.None)
            {
                writer.Write("<br/>");
                //非空
                if (this.blValEmpty)
                    this.ctrValEmpty.RenderControl(writer);

                //规则
                if (this.blValRegular && !this.ctrValRegular.ValidationExpression.Equals(string.Empty))
                    this.ctrValRegular.RenderControl(writer);

                //范围
                if (this.blValRange && (this.inputtype == textType.Int || this.inputtype == textType.Float || this.inputtype == textType.String))
                {
                    if (this.inputtype == textType.String)
                    {
                        ctrValRangeString.RenderControl(writer);
                        if (!this.Page.ClientScript.IsStartupScriptRegistered(txtConstants.strRangeScirpt))
                            this.Page.ClientScript.RegisterStartupScript(this.GetType(), txtConstants.strRangeScirpt, this.GetValRangeScript(), false);
                    }
                    else
                        this.ctrValRange.RenderControl(writer);
                }

                if (this.blValDanger)
                    this.ctrValDanger.RenderControl(writer);
            }
            #endregion

            ////用于验证除日期以外的的脚本处理方法
            //if (InputType != textType.Date)
            //{
                if (!this.Page.ClientScript.IsStartupScriptRegistered(txtConstants.strRegName))
                    this.Page.ClientScript.RegisterStartupScript(this.GetType(), txtConstants.strRegName, this.regBaseInputScript(), false);
            //}
        }

        protected override void CreateChildControls()
        {
            if (!ChildControlsCreated)
            {
                string strName = this.strValName.Equals(string.Empty) ? string.Empty : string.Format(txtConstants.MsgValNameFormat, this.strValName);

                this.ctrValEmpty.ControlToValidate = this.ctrValRegular.ControlToValidate = this.ctrValRangeString.ControlToValidate = this.ctrValRange.ControlToValidate = this.ID;
                this.ctrValEmpty.Display = this.ctrValRegular.Display = this.ctrValRange.Display = this.ctrValRangeString.Display = this.eDisplay;
                this.ctrValEmpty.ValidationGroup = this.ctrValRange.ValidationGroup = this.ctrValRegular.ValidationGroup = this.ctrValRangeString.ValidationGroup = this.ValidationGroup;

                #region 非空验证
                if (this.blValEmpty)
                {
                    this.ctrValEmpty.ID = "ValEmpty" + this.ID;
                    if (this.ctrValEmpty.ErrorMessage.Equals(string.Empty))
                        this.ctrValEmpty.ErrorMessage = string.Format(txtConstants.MsgEmpty,strName);
                    this.ctrValEmpty.EnableViewState = false;
                    this.Controls.Add(this.ctrValEmpty);
                }
                #endregion

                #region 规则验证
                if (this.blValRegular && !this.ctrValRegular.ValidationExpression.Equals(string.Empty))
                {
                    this.ctrValRegular.ID = "ValRegular" + this.ID;
                    if (this.ctrValRegular.ErrorMessage.Equals(string.Empty))
                        this.ctrValRegular.ErrorMessage = string.Format(txtConstants.MsgRegular, strName);
                    this.ctrValRegular.EnableViewState = false;
                    this.Controls.Add(this.ctrValRegular);
                }
                #endregion

                #region 范围验证
                if (this.blValRange)
                {
                    
                    if (this.inputtype == textType.Int || this.inputtype == textType.Float)
                    {
                        if (this.ctrValRange.ErrorMessage.Equals(string.Empty))
                            this.ctrValRange.ErrorMessage = string.Format(txtConstants.MsgRange, strName, this.ctrValRange.MinimumValue, this.ctrValRange.MaximumValue);
                    }
                    else
                    {//为文本输入长度范围时
                        this.ctrValRangeString.ClientValidationFunction = txtConstants.strRangeScirpt;
                        StringBuilder sbRangeMsg = new StringBuilder();
                        if (this.ctrValRange.ErrorMessage.Equals(string.Empty))
                        {
                            int nValue = 0;
                            if (!this.ctrValRange.MinimumValue.Equals(string.Empty) && int.TryParse(this.ctrValRange.MinimumValue, out nValue) && nValue > 0)
                                sbRangeMsg.Append(string.Format(txtConstants.MsgRangeStringMin, this.ctrValRange.MinimumValue));


                            nValue = 0;
                            if (!this.ctrValRange.MaximumValue.Equals(string.Empty) && int.TryParse(this.ctrValRange.MaximumValue, out nValue) && nValue > 0)
                            {
                                if (sbRangeMsg.Length > 0)
                                    sbRangeMsg.Append(" and ");
                                sbRangeMsg.Append(string.Format(txtConstants.MsgRangeStringMax, this.ctrValRange.MaximumValue));
                            }

                            if (sbRangeMsg.Length > 0)
                            {
                                this.ctrValRangeString.ErrorMessage = string.Format(txtConstants.MsgRangeString, strName, sbRangeMsg.ToString());
                                ctrValRangeString.Attributes.Add("MinLength", this.ctrValRange.MinimumValue);
                                ctrValRangeString.Attributes.Add("MaxLength", this.ctrValRange.MaximumValue);
                                this.ctrValRangeString.EnableViewState = false;
                                this.Controls.Add(this.ctrValRangeString);
                            }
                        }
                        else
                        {
                            this.ctrValRangeString.ErrorMessage = this.ctrValRange.ErrorMessage;
                            this.ctrValRangeString.EnableViewState = false;
                            this.Controls.Add(this.ctrValRangeString);
                        }
                    }

                    switch (this.inputtype)
                    {
                        case textType.Int:
                            this.ctrValRange.Type = ValidationDataType.Integer;
                            break;
                        case textType.Float:
                            this.ctrValRange.Type = ValidationDataType.Double;
                            break;
                        default:
                            if (this.ctrValRange.MinimumValue.Equals(string.Empty) || this.ctrValRange.MaximumValue.Equals(string.Empty))
                                this.ctrValRange.Type = ValidationDataType.String;
                            else
                                this.ctrValRange.Type = ValidationDataType.Integer;
                            break;
                    }
                    this.ctrValRange.ID = "ValRange" + this.ID;
                    this.ctrValRange.EnableViewState = false;
                    this.Controls.Add(this.ctrValRange);
                }
                #endregion

                #region 危险字符验证
                if (this.blValDanger)
                {
                    this.ctrValDanger.Display = Display;
                    this.ctrValDanger.ErrorMessage = string.Format(txtConstants.MsgDanger, strName);
                    this.ctrValDanger.ID = "ValDanger" + this.ID;
                    this.ctrValDanger.ControlToValidate = this.ID;
                    this.ctrValDanger.ValidationExpression = txtConstants.valDanger;
                    this.ctrValDanger.EnableViewState = false;
                    this.Controls.Add(this.ctrValDanger);
                }
                #endregion
            }
        }

        /// <summary>
        /// 重写属性输出函数
        /// </summary>
        /// <param name="writer">要写出到的 HTML 编写器</param>
        protected override void AddAttributesToRender(HtmlTextWriter writer)
        {
            try
            {
                string outputScript = "";
                string onfocusScript = "";
                string inscript = "";
                bool onfocus = false;
                bool onblur = false;
                switch (InputType)
                {
                    case textType.ChineseLanguage: //输入中文
                        this.Attributes.Add("onkeypress", string.Format(txtConstants.Onkeypress, @"/^$/"));
                        this.Attributes.Add("onpaste", string.Format(txtConstants.Onpaste, txtConstants.valChineseLanguage));
                        this.Attributes.Add("ondrop", string.Format(txtConstants.Ondrop, txtConstants.valChineseLanguage));
                        break;
                    case textType.Float://浮点
                        string strForamt = @"/^\-?\d*\.?\d{0," + this.FloatLength + "}$/";
                        this.Attributes.Add("onkeypress", string.Format(txtConstants.Onkeypress, strForamt));
                        this.Attributes.Add("onpaste", string.Format(txtConstants.Onpaste, strForamt));
                        this.Attributes.Add("ondrop", string.Format(txtConstants.Ondrop, strForamt));
                        onfocus = true;
                        onblur = false;
                        break;
                    case textType.Lower://小写
                        this.Attributes.Add("onkeypress", string.Format(txtConstants.Onkeypress, txtConstants.valLower));
                        this.Attributes.Add("onpaste", string.Format(txtConstants.Onpaste, txtConstants.valLower));
                        this.Attributes.Add("ondrop", string.Format(txtConstants.Ondrop, txtConstants.valLower));
                        onfocus = true;
                        onblur = false;
                        break;
                    case textType.Int: //数字
                        this.Attributes.Add("onkeypress", string.Format(txtConstants.Onkeypress, txtConstants.valInt));
                        this.Attributes.Add("onpaste", string.Format(txtConstants.Onpaste, txtConstants.valInt));
                        this.Attributes.Add("ondrop", string.Format(txtConstants.Ondrop, txtConstants.valInt));
                        onfocus = true;
                        onblur = false;
                        break;
                    case textType.Phone:  //固话
                        this.Attributes.Add("onkeypress", string.Format(txtConstants.Onkeypress, txtConstants.valPhone));
                        this.Attributes.Add("onpaste", string.Format(txtConstants.Onpaste, txtConstants.valPhone));
                        this.Attributes.Add("ondrop", string.Format(txtConstants.Ondrop, txtConstants.valPhone));
                        onfocus = true;
                        onblur = false;
                        //inscript = "if(this.value.length<12&&this.value!=''){alert('" + this.ShowMessage + "');this.focus();this.select();}";
                        break;
                    case textType.Upper://大写
                        this.Attributes.Add("onkeypress", string.Format(txtConstants.Onkeypress, txtConstants.valUpper));
                        this.Attributes.Add("onpaste", string.Format(txtConstants.Onpaste, txtConstants.valUpper));
                        this.Attributes.Add("ondrop", string.Format(txtConstants.Ondrop, txtConstants.valUpper));
                        onfocus = true;
                        onblur = false;
                        break;
                    //case textType.Date: //日期
                    //    this.Attributes.Add("onfocus", string.Format(txtConstants.OnfocusDate, this.IsDisplayTime.ToString().ToLower(), this.strDateSplitFlag, this.strDateFormat));
                    //    break;
                }
                ////日期、IP、电话对其事件进行独自处理
                //if (!new StyleFilter().getFilter().Contains(InputType))
                //{
                //    if(!string.IsNullOrEmpty(this.onfocusCssName))
                //        this.Attributes.Add("onfocus", "this.className='"+this.onfocusCssName+"'");
                //    if (!string.IsNullOrEmpty(this.onblurCssName))
                //        this.Attributes.Add("onblur", "this.className='" + this.onblurCssName + "'");
                //}
                onfocusScript = getScript(true, onfocus, inscript);
                if (onfocusScript != "")
                    this.Attributes.Add("onfocus", onfocusScript);
                outputScript = getScript(false, onblur, inscript);
                if (outputScript != "")
                    this.Attributes.Add("onblur", outputScript);
                base.AddAttributesToRender(writer);
            }
            catch (Exception ex)
            {
                throw new ApplicationException(ex.ToString());
            }
        }

        #endregion

        #region 其它基本数据类型验证
        private string regBaseInputScript()
        {
            StringBuilder sbJS = new StringBuilder();
            sbJS.Append("<script language=\"javascript\" type=\"text/javascript\">");
            sbJS.Append("function regInput(obj, reg, inputStr)");
            sbJS.Append("{");
            sbJS.Append("     var docSel	= document.selection.createRange();");
            sbJS.Append("     if (docSel.parentElement().tagName != \"INPUT\")");
            sbJS.Append("         return false;");
            sbJS.Append("     oSel = docSel.duplicate();");
            sbJS.Append("     oSel.text = \"\";");
            sbJS.Append("     var srcRange	= obj.createTextRange();");
            sbJS.Append("     oSel.setEndPoint(\"StartToStart\", srcRange);");
            sbJS.Append("     var str = oSel.text + inputStr + srcRange.text.substr(oSel.text.length);");
            sbJS.Append("     return reg.test(str);");
            sbJS.Append("}</script>");
            return sbJS.ToString();
        }
        #endregion

        #region 脚本
//        /// <summary>
//        /// 文本框响应回车事件
//        /// </summary>
//        /// <returns></returns>
//        private string event_EnterScript()
//        {
//            return @"<script language='javascript' for='document' event='onkeydown'>
//                        if(event.srcElement.type=='text'&&event.keyCode==13)
//                            { event.keyCode=9;} </script>";
//        }

        private string GetValRangeScript()
        {
            StringBuilder sbScript = new StringBuilder();
            sbScript.Append("<script language='javascript'>function ValidatorForLength(obj,arg)")
            .Append("{var value = document.getElementById('").Append(this.ClientID).Append("').value;")
            .Append("var maxvalue = obj.getAttribute('MaxLength');")
            .Append("var minvalue = obj.getAttribute('MinLength');")
            .Append("if(maxvalue > 0 || minvalue > 0){")
            .Append("if(value.length > maxvalue || value.length < minvalue)")
            .Append("arg.IsValid = false;").Append(" }}</script>");
            return sbScript.ToString();
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="Focus">为失去集点</param>
        /// <param name="Flag"></param>
        /// <returns></returns>
        public string getScript(bool Focus, bool Flag, string inscript)
        {
            string script = "";
            if (!string.IsNullOrEmpty(Focus ? this.OnFocusCssName : this.OnBlurCssName))
                script = "this.className='" + (Focus ? this.OnFocusCssName : this.OnBlurCssName) + "';";
            if (Focus == false)
                script = inscript + script;
            if (Flag == true)
                script += "this.style.imeMode='disabled';";
            return script;
        }
        #endregion
    }
}
